/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package radiostation;

import javax.persistence.EntityManager;

/**
 *
 * @author profanis
 */
public class MainUI extends javax.swing.JFrame {

    EntityManager entityManager;

    public MainUI(EntityManager entityManager) {
        this.entityManager = entityManager;
        initComponents();
        
        // Ρυθμίζουμε το παράθυρο να εμφανίζεται στο κέντρο της οθόνης
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu5 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu7 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();

        jMenuItem5.setText("jMenuItem5");

        jMenu4.setText("jMenu4");

        jMenu5.setText("File");
        jMenuBar2.add(jMenu5);

        jMenu6.setText("Edit");
        jMenuBar2.add(jMenu6);

        jMenuItem6.setText("jMenuItem6");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(800, 600));
        setResizable(false);

        jMenu1.setText("Επιλογές");

        jMenu7.setText("Διαχείριση αρχείων");

        jMenuItem1.setText("Καλλιτέχνες");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showArtists(evt);
            }
        });
        jMenu7.add(jMenuItem1);

        jMenuItem2.setText("Συγκροτήματα");
        jMenuItem2.setToolTipText("");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showMusicGroups(evt);
            }
        });
        jMenu7.add(jMenuItem2);

        jMenuItem3.setText("Άλμπουμ συγκροτημάτων");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showMusicGroupAlbums(evt);
            }
        });
        jMenu7.add(jMenuItem3);

        jMenuItem4.setText("Άλμπουμ καλλιτεχνών");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showArtistAlbums(evt);
            }
        });
        jMenu7.add(jMenuItem4);

        jMenu1.add(jMenu7);

        jMenuItem7.setText("Λίστες τραγουδιών");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showPlaylist(evt);
            }
        });
        jMenu1.add(jMenuItem7);

        jMenuItem8.setText("Έξοδος");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitApplication(evt);
            }
        });
        jMenu1.add(jMenuItem8);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 716, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 449, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void showArtists(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showArtists
        ArtistUI artistUI = new ArtistUI(entityManager, this);
        artistUI.setVisible(true);
    }//GEN-LAST:event_showArtists

    private void exitApplication(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitApplication
        entityManager.close();
        System.exit(0);
    }//GEN-LAST:event_exitApplication

    private void showPlaylist(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showPlaylist
        PlaylistUI playlistUI = new PlaylistUI(entityManager, this);
        playlistUI.setVisible(true);
    }//GEN-LAST:event_showPlaylist

    private void showMusicGroups(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showMusicGroups
        MusicGroupUI musicGroupUI = new MusicGroupUI(entityManager, this);
        musicGroupUI.setVisible(true);
    }//GEN-LAST:event_showMusicGroups

    private void showMusicGroupAlbums(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showMusicGroupAlbums
        MusicGroupAlbumsUI musicGroupAlbumsUI = new MusicGroupAlbumsUI(entityManager, this);
        musicGroupAlbumsUI.setVisible(true);
    }//GEN-LAST:event_showMusicGroupAlbums

    private void showArtistAlbums(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showArtistAlbums
        ArtistAlbumsUI artistAlbumsUI = new ArtistAlbumsUI(entityManager, this);
        artistAlbumsUI.setVisible(true);
    }//GEN-LAST:event_showArtistAlbums


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    // End of variables declaration//GEN-END:variables
}
